fcnnvar_helper Derived Type

type, public :: fcnnvar_helper

Defines a type capable of encapsulating an equation of N variables.


Type-Bound Procedures

procedure, public :: fcn => fnh_fcn

  • private function fnh_fcn(this, x, args) result(f)

    Executes the routine containing the function to evaluate.

    Arguments

    Type IntentOptional Attributes Name
    class(fcnnvar_helper), intent(in) :: this

    The fcnnvar_helper object.

    real(kind=real64), intent(in), dimension(:) :: x

    The value of the independent variables at which the function should be evaluated.

    class(*), intent(inout), optional :: args

    An optional argument to allow the user to communicate with the routine.

    Return Value real(kind=real64)

    The value of the function.

procedure, public :: get_variable_count => fnh_get_nvar

  • private function fnh_get_nvar(this) result(n)

    Gets the number of variables in this system.

    Arguments

    Type IntentOptional Attributes Name
    class(fcnnvar_helper), intent(in) :: this

    The fcnnvar_helper object.

    Return Value integer(kind=int32)

    The number of variables.

procedure, public :: gradient => fnh_grad_fcn

  • private subroutine fnh_grad_fcn(this, x, g, fv, args)

    Computes the gradient of the function.

    Arguments

    Type IntentOptional Attributes Name
    class(fcnnvar_helper), intent(in) :: this

    The fcnnvar_helper object.

    real(kind=real64), intent(inout), dimension(:) :: x

    An N-element array containing the independent variables defining the point about which the derivatives will be calculated. This array is restored upon output.

    real(kind=real64), intent(out), dimension(:) :: g

    An N-element array where the gradient will be written upon output.

    real(kind=real64), intent(in), optional :: fv

    An optional input providing the function value at x.

    class(*), intent(inout), optional :: args

    An optional argument to allow the user to communicate with the routine.

procedure, public :: is_fcn_defined => fnh_is_fcn_defined

  • private function fnh_is_fcn_defined(this) result(x)

    Tests if the pointer to the function has been assigned.

    Arguments

    Type IntentOptional Attributes Name
    class(fcnnvar_helper), intent(in) :: this

    The fcnnvar_helper object.

    Return Value logical

    Returns true if the pointer has been assigned; else, false.

procedure, public :: is_gradient_defined => fnh_is_grad_defined

  • private function fnh_is_grad_defined(this) result(x)

    Tests if the pointer to the routine containing the gradient has been assigned.

    Arguments

    Type IntentOptional Attributes Name
    class(fcnnvar_helper), intent(in) :: this

    The fcnnvar_helper object.

    Return Value logical

    Returns true if the pointer has been assigned; else, false.

procedure, public :: set_fcn => fnh_set_fcn

  • private subroutine fnh_set_fcn(this, fcn, nvar)

    Establishes a pointer to the routine containing the function.

    Arguments

    Type IntentOptional Attributes Name
    class(fcnnvar_helper), intent(inout) :: this

    The fcnnvar_helper object.

    procedure(fcnnvar), intent(in), pointer :: fcn

    The function pointer.

    integer(kind=int32), intent(in) :: nvar

    The number of variables in the function.

procedure, public :: set_gradient_fcn => fnh_set_grad

  • private subroutine fnh_set_grad(this, fcn)

    Establishes a pointer to the routine containing the gradient vector of the function.

    Arguments

    Type IntentOptional Attributes Name
    class(fcnnvar_helper), intent(inout) :: this

    The fcnnvar_helper object.

    procedure(gradientfcn), intent(in), pointer :: fcn

    The pointer to the gradient routine.